from llvmlite import ir

from .base import BuiltinFunction, get_builtin_function_cls
from ...types import double


class Pow(BuiltinFunction):
    def register(self):
        printf_ty = ir.FunctionType(double, [double, double])
        self.func = ir.Function(self.module, printf_ty, name="pow")


class Sine(BuiltinFunction):
    def register(self):
        printf_ty = ir.FunctionType(double, [double])
        self.func = ir.Function(self.module, printf_ty, name="sin")


class Cosine(BuiltinFunction):
    def register(self):
        printf_ty = ir.FunctionType(double, [double])
        self.func = ir.Function(self.module, printf_ty, name="cos")


class Sqrt(BuiltinFunction):
    def register(self):
        printf_ty = ir.FunctionType(double, [double])
        self.func = ir.Function(self.module, printf_ty, name="sqrt")


class LogFunc(BuiltinFunction):
    def register(self):
        printf_ty = ir.FunctionType(double, [double])
        self.func = ir.Function(self.module, printf_ty, name="log")


builtin_math_funcs = get_builtin_function_cls(globals())
